Return to start page
Core/Debug/Library String.j
1 /// Test of all core string functions.
2 library ALibraryCoreDebugString requires ALibraryCoreDebugMisc, ACoreString
3
4 private function GetStringConversionDebug takes nothing returns nothing
5 debug call Print("GetTimeString - " + GetTimeString(120))
6 if (StringToPlayerColor("ff0000") == PLAYER_COLOR_RED) then
7 debug call Print("StringToPlayerColor - Works.")
8 else
9 debug call Print("StringToPlayerColor - Doesn't work.")
10 endif
11 debug call Print("PlayerColorToString - " + PlayerColorToString(PLAYER_COLOR_BLUE) + "Blue text")
12 endfunction
13
14 private function GetStringPoolFunctionsDebug takes string testString, string testParameter0 returns nothing
15 debug call Print("GetRandomCharacter - Result is \"" + GetRandomCharacter(testString) + "\".")
16 debug call Print("GetRandomAlphabeticalCharacter - Result is \"" + GetRandomAlphabeticalCharacter() + "\".")
17 debug call Print("GetRandomNumeralCharacter - Result is \"" + GetRandomNumeralCharacter() + "\".")
18 debug call Print("GetRandomSpecialCharacter - Result is \"" + GetRandomSpecialCharacter() + "\".")
19 debug call Print("GetRandomString - Result is \"" + GetRandomString(23, true, true, true) + "\".")
20 if (not IsStringFromCharacterPool(testString, testParameter0)) then
21 debug call Print("IsStringFromCharacterPool - Result is true.")
22 else
23 debug call Print("IsStringFromCharacterPool - Result is false.")
24 endif
25 if (IsStringAlphabetical(testString)) then
26 debug call Print("IsStringAlphabetical - Result is true.")
27 else
28 debug call Print("IsStringAlphabetical - Result is false.")
29 endif
30 if (IsStringNumeral(testString)) then
31 debug call Print("IsStringNumeral - Result is true.")
32 else
33 debug call Print("IsStringNumeral - Result is false.")
34 endif
35 if (IsStringSpecial(testString)) then
36 debug call Print("IsStringSpecial - Result is true.")
37 else
38 debug call Print("IsStringSpecial - Result is false.")
39 endif
40 if (IsStringInteger(testString)) then
41 debug call Print("IsStringInteger - Result is true.")
42 else
43 debug call Print("IsStringInteger - Result is false.")
44 endif
45 if (IsStringBinary(testString)) then
46 debug call Print("IsStringBinary - Result is true.")
47 else
48 debug call Print("IsStringBinary - Result is false.")
49 endif
50 if (IsStringOctal(testString)) then
51 debug call Print("IsStringOctal - Result is true.")
52 else
53 debug call Print("IsStringOctal - Result is false.")
54 endif
55 if (IsStringHexadecimal(testString)) then
56 debug call Print("IsStringHexadecimal - Result is true.")
57 else
58 debug call Print("IsStringHexadecimal - Result is false.")
59 endif
60 endfunction
61
62 function GetStringMiscFunctionsDebug takes string testString, string testParameter0, string testParameter1 returns nothing
63 if (FindString(testString, testParameter0) != -1) then
64 debug call Print("FindString - Found it.")
65 else
66 debug call Print("FindString - Did not find it.")
67 endif
68 debug call Print("ReplaceSubString - Result is \"" + ReplaceSubString(testString, 0, testParameter0) + "\"")
69 debug call Print("ReplaceString - Result is \"" + ReplaceString(testString, testParameter0, testParameter1) + "\"")
70 debug call Print("RemoveSubString - Result is \"" + RemoveSubString(testString, 0, StringLength(testParameter0)) + "\"")
71 debug call Print("RemoveString - Result is \"" + RemoveString(testString, testParameter0) + "\"")
72 debug call Print("InsertString - Result is \"" + InsertString(testString, 0, testParameter0) + "\"")
73 debug call Print("MoveSubString - Result is \"" + MoveSubString(testString, 0, StringLength(testParameter0), 0) + "\"") /// @todo Move to old position to prevent crashes
74 debug call Print("MoveString - Result is \"" + MoveString(testString, testParameter0, 0) + "\"") /// @todo Move to old position to prevent crashes
75 debug call Print("ReverseString - Result is \"" + ReverseString(testString) + "\"")
76 debug if (StringMatch(testString, testParameter0, true)) then
77 debug call Print("StringMatch - Result is true.")
78 debug else
79 debug call Print("StringMatch - Result is false.")
80 debug endif
81 endfunction
82
83 function AStringDebug takes nothing returns nothing
84 local string testString = "Lieber Peter, gestern ging es mir gut."
85 local string testParameter0 = "ging"
86 local string testParameter1 = "auch"
87 call GetStringConversionDebug()
88 call GetStringPoolFunctionsDebug(testString, testParameter0)
89 call GetStringMiscFunctionsDebug(testString, testParameter0, testParameter1)
90 endfunction
91
92 endlibrary